<?php

/**
 * User form.
 *
 * @package    BootcampApp
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class UserForm extends BaseUserForm {

    public function configure() {

        $this->configureWidgets();
        $this->configureFieldLabels();

        $this->getWidgetSchema()->setHelp('email', 'E-mail confirmation is required, please use your real e-mail address');
    }

    /**
     * Sets label to display in form render
     */
    private function configureFieldLabels() {
        $this->getWidget('firstname')->setLabel('First name');
        $this->getWidget('lastname')->setLabel('Last name');
        $this->getWidget('email')->setLabel('E-mail address');
        $this->getWidget('address')->setLabel('street address');
        $this->getWidget('locality')->setLabel('city');
        $this->getWidget('postal_code')->setLabel('postal code');
        $this->getWidget('state')->setLabel('state / province');
        $this->getWidget('birthday')->setLabel('date of birth (m/d/y)');
        $this->getWidget('country_id')->setLabel('Country');
        $this->getWidget('timezone_id')->setLabel('time zone');
        $this->getWidget('biography')->setLabel('Bio');
    }
    
    /**
     * Configure widgets
     */
    private function configureWidgets(){ 
        $this->setWidget('biography', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('biography')->getOption('max_length'))));
        
        $years = range(date('Y'), date('Y') - 100);
        $this->getWidget('birthday')->setOption('years', array_combine($years, $years));

        $this->setValidator('email', new sfValidatorEmail(array(), array('invalid' => 'Invalid e-mail account')));
    }

}
